What is INT( 25.50 )?

Answer:

25

The fractional part of a positive number is just dropped, regardless of what it is.

Random Columns and Rows

Look at the program:

SCREEN 12
FOR DOT = 1 to 10000
  LET X = INT( 640*RND )    ' pick a random column 0 to 639
  LET Y = INT( 480*RND )    ' pick a random row    0 to 479 
  PSET( X, Y)               ' draw the random point
NEXT DOT
'
END

The statement that picks a value for X works like this:

  LET X = INT( 640*RND )
      ^    ^    ^   ^
      |    |    |   |
      |    |    |   +---- (1) Pick a random value 0.0 to 0.99999
      |    |    |
      |    |    +--- (2) multiply it by 640, yielding a value 0.0 to 639.99999
      |    |
      |    +---- (3) change it to an integer 0 to 639
      |
      +---- (4) Finally, store the result in the variable X. 

The value in X, 0 to 639, is the number on one of the columns of graphics screen 12. PSET will set a pixel in one of those columns, but we don't know which one.

The same thing is done for Y, so Y will contain an integer that designates one of the rows of the graphics screen, but we don't know which one. The combination of X and Y designates some pixel of the screen, but we don't know at all which one. It is as if all pixels were placed "in a hat" and one of them chosen at random.

The next time the loop body is executed, RND will be used two more times, and a new pixel will be chosen. RND does not keep track of what numbers it has picked in the past. It might pick the same number more than once (although this is rare.) So each time a pixel is chosen, it is as if all of them were in the hat (including pixels that have been picked before) and one of them chosen. Usually you will get a never-before-picked pixel, but there will be occasional repeats.

QUESTION 19:

If several thousand spots were put on the screen, could you accurately estimate how many there were?